package it.ap.sa.acqua.hibernate.dialect;

import it.ap.sa.acqua.hibernate.custom.function.TplSqlConversionFunction;
import it.ap.sa.acqua.hibernate.custom.function.time.TplFormattaOrarioFunction;
import it.ap.sa.acqua.hibernate.custom.function.time.TplFormattaOrarioSenzaSecondiFunction;
import it.ap.sa.acqua.hibernate.custom.function.time.TplOrarioFormattatoToSecondsFunction;
import it.ap.sa.acqua.hibernate.custom.function.time.TplOrarioToSecondsFunction;
import it.ap.sa.acqua.hibernate.custom.function.time.TplSecondsToOrarioFunction;
import it.ap.sa.core.dao.util.JsonPostgreSQLDialect;

/**
 * @author Alessandro Paolillo
 */
public class PostgresDialect extends JsonPostgreSQLDialect{

	private static final long serialVersionUID = -5323938489424042988L;

	public PostgresDialect() {
		super();
		this.addFucntions();
	}
	/**
	 * @author Alessandro Paolillo
	 */
	private void addFucntions(){
		this.addTplSqlConversionFunction(new TplFormattaOrarioFunction            ());
		this.addTplSqlConversionFunction(new TplFormattaOrarioSenzaSecondiFunction());
		this.addTplSqlConversionFunction(new TplOrarioFormattatoToSecondsFunction ());
		this.addTplSqlConversionFunction(new TplOrarioToSecondsFunction           ());
		this.addTplSqlConversionFunction(new TplSecondsToOrarioFunction           ());
		
	}
	/**
	 * @author Alessandro Paolillo
	 */
	private void addTplSqlConversionFunction(TplSqlConversionFunction function){
		this.registerFunction(function.getSqlFunction(), function);
		
	}

}
